import { Base } from '../../../utils/base.js';
//var base =require('../../utils/base.js').base;
class List extends Base {
  constructor() {
    super();
  }
  getOrder(id,callback) {
    var that = this;
    var params = {
      url: 'order/getOrder/'+id,
      sCallback: function (data) {
        callback && callback(data);
      }
    };
    this.request(params);
  }
  execPay(orderNumber, callback) {
    var allParams = {
      url: 'pay/pre_order',
      type: 'post',
      data: { order_no: orderNumber },
      sCallback: function (data) {
        var timeStamp = data.timeStamp;
        if (timeStamp) { //可以支付
          wx.requestPayment({
            'timeStamp': timeStamp.toString(),
            'nonceStr': data.nonceStr,
            'package': data.package,
            'signType': data.signType,
            'paySign': data.paySign,
            success: function () {
              callback && callback(2);
            },
            fail: function () {
              callback && callback(1);
            }
          });
        } else {
          callback && callback(0);
        }
      }
    };
    this.request(allParams);
  }
};

export { List };
